# -*- coding: utf-8 -*-
import random


class HeaderUtil:

    agent_pool = ["User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
                  "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"]

    def __init__(self):
        pass

    '''
    伯乐在线的数据获取，头里需要添加一个host名称，这个Host可以从URL里获取信息进行组织
    '''
    @classmethod
    def get_common_request_header(cls, host_name):
        if not host_name:
            host_name = "www.jobbole.com"
        agent = random.choice(cls.agent_pool)
        headers = {
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            "Accept-Encoding": "gzip, deflate",
            "Accept-Language": "zh-CN,zh;q=0.9",
            "Connection": "keep-alive",
            "Host": host_name,
            "Upgrade-Insecure-Requests": 1,
            "User-Agent": agent,
        }
        return headers
